import 'package:flutter/material.dart';

class ComponentGradientTextButton extends StatelessWidget {
  const ComponentGradientTextButton({
    Key? key,
    this.gradient,
    required this.onTap,
    required this.title,
    this.textStyle,
    this.width,
    this.height,
    this.radius,
    this.padding,
    this.color,
    this.textColor,
  }) : super(key: key);

  // 标题
  final String title;

  // 标题样式
  final TextStyle? textStyle;

  // 渐变
  final LinearGradient? gradient;

  // 点击回调
  final VoidCallback onTap;

  // 宽
  final double? width;

  // 高
  final double? height;

  // 圆角
  final double? radius;
  final EdgeInsets? padding;
  final Color? color;
  final Color? textColor;

  @override
  Widget build(BuildContext context) {
    double circleRadius = radius ?? 40;
    return Material(
      clipBehavior: Clip.hardEdge,
      borderRadius: radius == null
          ? BorderRadius.circular(circleRadius)
          : BorderRadius.circular(radius!),
      child: Ink(
        width: width,
        height: height,
        decoration: BoxDecoration(
            color: color ?? Theme.of(context).primaryColor,
            // gradient: gradient??const LinearGradient(begin: Alignment.centerLeft,end: Alignment.centerRight,colors: [
            //   AppColors.contentColorBlue,
            //   AppColors.contentColorCyan
            // ]),
            borderRadius: BorderRadius.circular(circleRadius)),
        child: InkWell(
          onTap: onTap,
          borderRadius: BorderRadius.all(Radius.circular(circleRadius)),
          child: Center(
            child: Padding(
              padding: padding ?? const EdgeInsets.symmetric(vertical: 14),
              child: Text(
                title,
                style: textStyle ??
                    TextStyle(
                        fontWeight: FontWeight.bold,
                        color: textColor ?? Colors.white),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
